package io.renren.modules.back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.back.dao.AttributeCategoryDao;
import io.renren.modules.back.entity.AttributeCategoryEntity;
import io.renren.modules.back.service.AttributeCategoryService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 商品属性分类service接口实现类
 *
 * @author zzh
 * @email 862583291@qq.com
 * @date 2018年12月10日 上午15:28:55
 */
@Service("attributeCategoryService")
public class AttributeCategoryServiceImpl  extends ServiceImpl<AttributeCategoryDao, AttributeCategoryEntity> implements AttributeCategoryService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = (String)params.get("name");
        String enabled = (String)params.get("enabled");
        Page<AttributeCategoryEntity> page = (Page<AttributeCategoryEntity>) this.page(
                new Query<AttributeCategoryEntity>(params).getPage(),
                new QueryWrapper<AttributeCategoryEntity>()
                        .like(StringUtils.isNotBlank(name),"name", name)
                        .eq(StringUtils.isNotBlank(enabled),"enabled", enabled)
        );
        return new PageUtils(page);
    }
}
